package com.rentcarRepair.controller.api;

import com.eight.pojo.TbMaintainShop;
import com.eight.vo.ComResult;
import com.rentcarRepair.service.impl.maintainShopServiceImpl;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDateTime;

/**
 * @author caoch
 * @since 2023/2/27 10:48
 **/
@RestController
@RequestMapping("rentcar-repair/api")
public class maintainShopApiController {
	@Resource(name ="maintainShopServiceImpl" )
	private maintainShopServiceImpl maintainShopService;
	@RequestMapping("addShop")
	public ComResult addShop(@RequestBody TbMaintainShop shop) {
		shop.setAddtime(LocalDateTime.now());
		return new ComResult(2000,"success",maintainShopService.addShop(shop)) ;
	}
	@RequestMapping("updateShop")
	public ComResult updateShop(@RequestBody TbMaintainShop shop) {
		return new ComResult(2000,"success",maintainShopService.updateShop(shop));
	}
	@RequestMapping("removeShop/{id}")
	public ComResult removeShop(@PathVariable int id) {
		return new ComResult(2000,"success",maintainShopService.removeShop(id));
	}
	@RequestMapping("selectShop")
	public ComResult select(@RequestParam(defaultValue = "1")Integer currentPage,
	                        @RequestParam(defaultValue = "5")Integer pageSize,
	                        @RequestBody TbMaintainShop shop ) {
		return new ComResult(2000,"success",maintainShopService.selectShop(currentPage,pageSize,shop));
	}

}
